//Problem Id:1013  User Id:tq 
//Memory:32K  Time:46MS
//Language:C++  Result:Accepted

/*	author: TangQiao @ Wind 
	problem name:Knight Moves
	source : ULM 1996
	problem type: 动态规划 || 搜索
	problem description: 在国际象棋的棋盘上(8x8),给出马的起始位置和目标位置,求最少几步可以跳到目标位置.
	problem solution: 广度优先搜索	 	
	date : 2005.5.20 北师大校队个人选拨赛1
	
*/ 

#include <stdio.h>
#include <string.h>
#include <math.h>

int tu[10][10];
int inx,iny;
int tox,toy;
int movex[8]={-1,-1,-2,-2,+1,+1,+2,+2};
int movey[8]={-2,+2,-1,+1,-2,+2,-1,+1};

char ss[10];
char ss2[10];

struct line1
{
	int x,y;
}st[10000],st2[10000];
int n1,n2;

void init()
{
	int i, j;
	for (i=0; i<=9; i++)
		for (j=0;j<=9;j++)
			tu[i][j]=10000;
	inx=ss[0]-'a'+1;
	iny=ss[1]-'0';

	tox=ss2[0]-'a'+1;
	toy=ss2[1]-'0';
//test:
//	printf("inxy=(%d,%d),toxy=(%d,%d)\n",inx,iny,tox,toy);

}



int nofind()
{
	if (tu[tox][toy]!=10000) return 0;
	else return 1;
}


main()
{
	int i, j, k;
	int a, b;
	int tot, step;
	int n;


	while (scanf("%s %s",ss,ss2)!=EOF)
	{
		if (strlen(ss)==0) break;
	
		init();

		tu[inx][iny]=0;

		st[1].x=inx;
		st[1].y=iny;
		n1=1;
		n2=0;
		step=0;
		while (nofind())
		{
			step++;
			for (i=1;i<=n1;i++)
			{
				for (k=0;k<8;k++)
				{
						a=st[i].x+movex[k];
						b=st[i].y+movey[k];
						if (a>0 && a<9 && b>0 && b<9 && (tu[a][b]==10000))
						{
							n2++;
							st2[n2].x=a;
							st2[n2].y=b;
							tu[a][b]=step;
						}
				}
			}

			for (i=1;i<=n2;i++)
			{
				st[i]=st2[i];				
			}
			n1=n2;
			n2=0;

		}
		printf("To get from %s to %s takes %d knight moves.\n",ss,ss2,tu[tox][toy]);



	} //end of while 
	




	return 0;
}

